<template>
  <BoTable
    :columns="columns"
    :request="_list"
    ref="tableRef"
    height="auto"
  ></BoTable>
</template>

<script setup lang="tsx">
import { computed, nextTick } from 'vue';
import { useDicts } from '@boeyo/portal';
import {
  BoFormProps,
  BoTable,
  BoTableProps,
  ConfigProvideProps,
  ConfigProvider,
} from '@boeyo/ui';
import dayjs from 'dayjs';
import { list } from './api';

const dictArr = ['sys_magnitude', 'sys_earthevent_type'];
const { sysMagnitudeEnum, sysEartheventTypeEnum } = useDicts(dictArr);
const _list = async (params) => {
  params.startTime = params.oritime ? dayjs(params.oritime[0]).valueOf() : null;
  params.endTime = params.oritime ? dayjs(params.oritime[1]).valueOf() : null;
  if (!params.oritime) {
    delete params.startTime;
    delete params.endTime;
  }
  const res: any = await list(params);
  return {
    total: res.total,
    rows: res.rows,
  };
};

const columns = computed<BoTableProps['columns']>(() => [
  // {
  //   title: '消息发布ID',
  //   dataIndex: 'id',
  //   hideInSearch: true,
  // },
  {
    title: '消息类型',
    dataIndex: 'msgType',
    hideInSearch: true,
    valueEnum: {
      ...sysEartheventTypeEnum.value,
    },
  },
  {
    title: '事件ID',
    dataIndex: 'eewId',
    hideInSearch: true,
  },
  {
    title: '震中地名',
    dataIndex: 'locname',
    // hideInSearch: true,
    ellipsis: true,
  },
  {
    title: '经度',
    dataIndex: 'longitude',
    hideInSearch: true,
  },
  {
    title: '纬度',
    dataIndex: 'latitude',
    hideInSearch: true,
  },
  {
    title: '震级',
    dataIndex: 'magnitude',
    valueType: 'select',
    valueEnum: {
      ...sysMagnitudeEnum.value,
    },
  },
  {
    title: '发震时间',
    dataIndex: 'oritime',
    valueType: 'dateRange',
  },

  // {
  //   title: '项目名称',
  //   dataIndex: 'project',
  //   hideInTable: true,
  // },
  // {
  //   title: '测点名称',
  //   dataIndex: 'ceDian',
  //   hideInTable: true,
  // },
  // {
  //   title: '设备类型',
  //   dataIndex: 'deviceType',
  //   hideInTable: true,
  //   valueEnum: {},
  //   valueType: 'select',
  // },
]);
</script>

<style lang="scss" scoped></style>
<route lang="json">
{
  "name": "地震事件查询",
  "meta": { "title": "地震事件查询" }
}
</route>
